<?php

/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Sitealbum
 * @copyright  Copyright 2010-2011 BigStep Technologies Pvt. Ltd.
 * @license    http://www.socialengineaddons.com/license/
 * @version    $Id: index.tpl 2011-08-026 9:40:21Z SocialEngineAddOns $
 * @author     SocialEngineAddOns
 */
?>
<?php 
	$this->headLink()
  ->appendStylesheet($this->layout()->staticBaseUrl
    . 'application/modules/Sitealbum/externals/styles/style_sitealbum.css')
?>
<?php
if($this->showLightBox):
include_once APPLICATION_PATH . '/application/modules/Sitealbum/views/scripts/_lightboxPhoto.tpl';
endif;
?>
<?php if($this->paginator->count() >0):?>
<script type="text/javascript">
  en4.core.runonce.add(function(){

    <?php if( !$this->renderOne ): ?>
    var anchor = $('profile_albums').getParent();
    $('profile_sitealbums_previous').style.display = '<?php echo ( $this->paginator->getCurrentPageNumber() == 1 ? 'none' : '' ) ?>';
    $('profile_sitealbums_next').style.display = '<?php echo ( $this->paginator->count() == $this->paginator->getCurrentPageNumber() ? 'none' : '' ) ?>';

    $('profile_sitealbums_previous').removeEvents('click').addEvent('click', function(){
      en4.core.request.send(new Request.HTML({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        data : {
          format : 'html',
          subject : en4.core.subject.guid,
          page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() - 1) ?>
        }
      }), {
        'element' : anchor
      })
    });

    $('profile_sitealbums_next').removeEvents('click').addEvent('click', function(){
      en4.core.request.send(new Request.HTML({
        url : en4.core.baseUrl + 'widget/index/content_id/' + <?php echo sprintf('%d', $this->identity) ?>,
        data : {
          format : 'html',
          subject : en4.core.subject.guid,
          page : <?php echo sprintf('%d', $this->paginator->getCurrentPageNumber() + 1) ?>
        }
      }), {
        'element' : anchor
      })
    });
    <?php endif; ?>
  });
</script>

<ul id="profile_albums" class="thumbs">
  <?php foreach( $this->paginator as $album ): ?>
    <li>
      <a class="thumbs_photo" href="<?php echo $album->getHref(); ?>">
        <span style="background-image: url(<?php echo $album->getPhotoUrl('thumb.normal'); ?>);"></span>
      </a>
      <p class="thumbs_info">
        <span class="thumbs_title">
          <?php echo $this->htmlLink($album, $this->string()->chunk($this->string()->truncate($album->getTitle(), 45), 10)) ?>
        </span>
        <?php echo $this->translate(array('%s photo', '%s photos', $album->count()),$this->locale()->toNumber($album->count())) ?>
      </p>
    </li>
  <?php endforeach;?>
</ul>
<div>
  <div id="profile_sitealbums_previous" class="paginator_previous">
    <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Previous'), array(
      'onclick' => '',
      'class' => 'buttonlink icon_previous'
    )); ?>
  </div>
  <div id="profile_sitealbums_next" class="paginator_next">
    <?php echo $this->htmlLink('javascript:void(0);', $this->translate('Next'), array(
      'onclick' => '',
      'class' => 'buttonlink_right icon_next'
    )); ?>
  </div>
</div>
<br /><br />
<?php endif; ?>
<?php $count=count($this->taggedInOthersPhotos); ?>
<?php if(!empty ($count)): ?>
<div>
	<h3>
	  <?php echo $this->translate("Photos of %s",$this->subject()->getTitle())?>
	</h3>
  <ul id="profile_albums" class="thumbs thumbs_nocaptions">
	  <?php 	$i = 0; ?>
	  <?php foreach( $this->taggedInOthersPhotos as $value ): ?>
	    <?php	$photo=Engine_Api::_()->getItem('album_photo', $value->resource_id); ?>
	    <li>
	      <a class="thumbs_photo" href="<?php echo $photo->getHref(); ?>" <?php if($this->showLightBox): ?>onclick='openLightBoxAlbum("<?php echo $photo->getPhotoUrl()?>","<?php echo Engine_Api::_()->sitealbum()->getLightBoxPhotoHref($photo,array_merge($this->params, array('offset'=>$i))); ?>");return false;' <?php endif; ?>>
	        <span style="background-image: url(<?php echo $photo->getPhotoUrl('thumb.normal'); ?>);"></span>
	      </a>
	    </li>
	   <?php 	$i++; ?>
	  <?php endforeach;?>
	</ul>
</div>
<?php endif; ?>

